//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package nc.bs.pub.action;

import nc.bs.framework.common.NCLocator;
import nc.bs.pubapp.pf.action.AbstractPfAction;
import nc.bs.so.m32.plugin.Action32PlugInPoint;
import nc.impl.pubapp.pattern.rule.IRule;
import nc.impl.pubapp.pattern.rule.processer.CompareAroundProcesser;
import nc.impl.so.m32.action.UnCommitSaleInvoiceAction;
import nc.impl.so.m32.action.rule.uncommit.CheckUnCommitEnableRule;
import nc.impl.so.m32.action.rule.uncommit.SetUnCommitValueRule;
import nc.uapbd.vo.sever.ListenerSever;
import nc.vo.pub.BusinessException;
import nc.vo.so.m32.entity.SaleInvoiceVO;
import nc.vo.to.m5f.entity.SettleListVO;

public class N_32_UNSAVE extends AbstractPfAction<SaleInvoiceVO> {
    public N_32_UNSAVE() {
    }

    protected CompareAroundProcesser<SaleInvoiceVO> getCompareAroundProcesserWithRules(Object userObj) {
        CompareAroundProcesser<SaleInvoiceVO> processor = new CompareAroundProcesser(Action32PlugInPoint.UnSendAppAction);
        this.addRule(processor);
        return processor;
    }

    protected SaleInvoiceVO[] processBP(Object userObj, SaleInvoiceVO[] clientFullVOs, SaleInvoiceVO[] originBills) {
        SaleInvoiceVO[] bills = (new UnCommitSaleInvoiceAction()).unSend(clientFullVOs, originBills);
        for (SaleInvoiceVO vo1: bills) {
            try {
                NCLocator.getInstance().lookup(ListenerSever.class).updataSH(vo1.getParentVO().getCsaleinvoiceid());
            } catch (BusinessException e) {
                nc.vo.pubapp.pattern.exception.ExceptionUtils.wrappBusinessException(e.getMessage());
            }
        }
        return bills;
    }

    private void addRule(CompareAroundProcesser<SaleInvoiceVO> processer) {
        IRule<SaleInvoiceVO> rule = new CheckUnCommitEnableRule();
        processer.addBeforeRule(rule);
        IRule<SaleInvoiceVO> rules = new SetUnCommitValueRule();
        processer.addBeforeRule(rules);
    }
}
